import App from './App.vue'
import { createApp } from 'vue'
import ElementPlus from 'element-plus';
import 'element-plus/dist/index.css';
import 'highlight.js/styles/atom-one-dark.css'
import 'highlight.js/lib/common'
import hljsVuePlugin from '@highlightjs/vue-plugin'
import './main.css'
const modulesFiles = import.meta.globEager('./core/*.js');
console.log(modulesFiles);
let core = {},util = {};
for (const path in modulesFiles) {
  var key = path.match(/\/([^\/.]+)\.[^.]+$/)[1]  
  console.log(modulesFiles[path]);
  core[key] = modulesFiles[path].default 
  Object.assign(util,core[key])
}
console.log(core);
console.log(util);
window.core = core
window.util = util

util.writeFile = async function(obj,name ='wz.json'){
  var { home } = await Niva.api.os.dirs()  
  Niva.api.fs.write(home+"/"+name,JSON.stringify(obj))
}
util.readFile = async function (name ='wz.json'){
  var { home } = await Niva.api.os.dirs() 
  console.log( home ); 
  var exists =  await Niva.api.fs.exists(home+"/"+name)
  console.log(121,exists); 
  if(exists){
   var res = await Niva.api.fs.read(home+"/"+name)
   return JSON.parse(res)
  }else{
   return {}
  }
}

createApp(App).use(ElementPlus).use(hljsVuePlugin).mount('#app')
/*
https://github1s.com/guillaumepotier/validator.js

https://www.jianshu.com/p/fb527385d0ec

jquery 
https://blog.csdn.net/qq_34755766/article/details/83475903

writeFile(obj,name ='wz.json'){
  
}
*/
